#ifndef ULTOA_H
#define ULTOA_H

#include <string>

inline char* ultoa(unsigned long value, char* orig_buf)
{
	char * buf = orig_buf;
	
	//check 0 value
	if (value ==0)
	{
		*(buf++) = '0';
		*buf = '\000';
		return orig_buf;
	}
	
	
	char tmp[32];
	int i = 0;
	while (value)
	{
		tmp[i++] = (value % 10) + '0';
		value /=10;
	}
	while (i--)
		*(buf++) =tmp[i];
	*buf = '\000';
	return orig_buf;
}

inline std::string& ultoa(unsigned long value, std::string& buf)
{
	//check 0 value
	if (value ==0)
	{
		buf += '0';
		return buf;
	}
	
	char tmp[32];
	int i = 0;
	while (value)
	{
		tmp[i++] = (value % 10) + '0';
		value /=10;
	}
	while (i--)
		buf += tmp[i];
	return buf;
}

#endif

